package com.ls.enums;

public enum OrderRecordEnum {
    /**
     * 会员等级1
     */
    LEVEL1(1,1000,1),

    /**
     * 会员等级2
     */
    LEVEL2(1001,10000,2),

    /**
     * 会员等级3
     */
    LEVEL3(10001,50000,3);
    public Integer pointsMin;
    public Integer pointsMax;
    public Integer grade;
    OrderRecordEnum(Integer pointsMin, Integer pointsMax,Integer grade) {
        this.pointsMin = pointsMin;
        this.pointsMax = pointsMax;
        this.grade = grade;
    }
    public static Integer getOrderRecordEnum(long points) {
        for (OrderRecordEnum value : OrderRecordEnum.values()) {
            if(points==0){
                return 0;
            }else if (points >= value.pointsMin && points <= value.pointsMax) {
                return value.grade;
            }
        }
        return null;
    }
    public static Integer getLowerScore(Integer score) {
        for (OrderRecordEnum value : OrderRecordEnum.values()) {
            if (score==0){
                return 1;
            }else if (score >= value.pointsMin && score <= value.pointsMax) {
                return value.pointsMax-score;
            }
        }
        return null;
    }
}
